import React, { useState } from "react";
import { Table } from "@nutui/nutui-react-taro";
import { useRequest } from "ahooks";
import {
  getDevelopUserApi,
  getKickbackApi,
  getOverdueUserApi,
  getRentUserApi,
} from "../../../../servers/servers";
import { useMemo } from "react";

const DeveUserTable = () => {
  // 在租用户数
  const { data: kickData } = useRequest(async () => {
    const _res = await getKickbackApi();
    return _res?.data;
  });

  const [columns] = useState([
    {
      title: "",
      key: "type",
    },
    {
      title: "当月用户",
      key: "current",
    },
    {
      title: "预估收入",
      key: "will",
    },
  ]);

  const data = useMemo(() => {
    if (!kickData) return [];

    return [
      {
        type: "发展用户",
        current: kickData?.develop?.current,
        will: kickData?.develop?.estimate,
      },
      {
        type: "单电用户",
        current: kickData?.single?.current,
        will: kickData?.single?.estimate,
      },
      {
        type: "车电用户",
        current: kickData?.vehicle?.current,
        will: kickData?.vehicle?.estimate,
      },
      {
        type: "",
        current: "逾期数量",
        will: "超30天数量",
      },
      {
        type: "逾期用户",
        current: kickData?.overdue, //当月用户
        will: kickData?.beyond,
      },
    ];
  }, [kickData]);

  return <Table columns={columns} data={data} />;
};
export default DeveUserTable;
